package by.ins.life.simpleimpl;

import java.io.Serializable;
import java.util.List;

import by.ins.life.IData;
import by.ins.life.ILife;
import by.ins.life.ISolver;
import by.ins.life.evolution.GoalItem;
import by.ins.life.evolution.IInaccuracyCounter;
import by.ins.life.evolution.ILifeEvoluter;
import by.ins.life.evolution.ISetEvoluter;
import by.ins.life.evolution.ITestGoalsProvider;
import by.ins.life.impl.Data;

public class SetEvoluter<T> implements ISetEvoluter<T>, Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	protected ILifeEvoluter<T> evol;
	
	ITestGoalsProvider<T> testGoalsProvider;
	IInaccuracyCounter<T> inaccuracyCounter;
	ISolver<T> solver;


	protected SetEvoluter(ILifeEvoluter<T> evol) {
		this.evol = evol;

	}
	
	public SetEvoluter(){
		
		
	}

	public ILifeEvoluter<T> getEvol() {
		return evol;
	}

	public void setEvol(ILifeEvoluter<T> evol) {
		this.evol = evol;
	}

	public ITestGoalsProvider<T> getTestGoalsProvider() {
		return testGoalsProvider;
	}

	public void setTestGoalsProvider(ITestGoalsProvider<T> testGoalsProvider) {
		this.testGoalsProvider = testGoalsProvider;
	}

	public IInaccuracyCounter<T> getInaccuracyCounter() {
		return inaccuracyCounter;
	}

	public void setInaccuracyCounter(IInaccuracyCounter<T> inaccuracyCounter) {
		this.inaccuracyCounter = inaccuracyCounter;
	}

	public ISolver<T> getSolver() {
		return solver;
	}

	public void setSolver(ISolver<T> solver) {
		this.solver = solver;
	}

	@Override
	public void evoluteSet(ILife<T> life) {
		
		List<GoalItem<T>> tests =  testGoalsProvider.getTestData(life.getCurrentEvilutionIndex() );
		for(GoalItem<T> gi : tests){
			solver.solve(life.getSet(), gi);
			 T t = inaccuracyCounter.calculateInaccurancy(gi);
			// gi.set
		}
		
		
		
//		throw new UnsupportedOperationException("Method is not implemented");
	}
	
protected IData<T> caculateDiffInaccurancy(List < GoalItem<T>> gis){
	IData<T>  result = new Data<T>(gis.size());
	
	for(GoalItem<T> gi :gis){
		result.add(gi.getCorrectDicision().get(0));
		for(int i = 1; i < gi.getCorrectDicision().size(); i++  ){
		//	Math.
		}
	}
	
	
	
	return result;
}



	
}
